<?php

class db
{
	public function connectdb()
	{
		include 'dbconfig.php';
		$con=mysql_connect($dbhost,$dbuser,$dbpass);
		if($con){
			mysql_select_db($dbname);
			mysql_query("SET NAMES 'UTF8'");
		}
		else{
			echo "connect fail";
		}
		
	}
	public function query($sql)
	{
		$result=mysql_query($sql);
		return $result;
	}
	public function close()
	{
		mysql_close();
	}
	public function select($sql)//返回结果数组
	{
		$result=mysql_query($sql);
		$end=array();//定义空数组
		while($row=mysql_fetch_array($result))
		{
			$end[]=$row;
		}
		return $end;
	}
}
?>